package com.iecas.handler;

import com.iecas.context.GlobalContext;
import com.iecas.context.ServerContext;
import com.iecas.enums.BizEnum;
import com.iecas.enums.ResponseEnum;
import com.iecas.launch.Client;
import com.iecas.launch.Server;
import com.iecas.request.DistributeReq;
import com.iecas.request.Root;
import com.iecas.response.BaseResponse;
import com.iecas.response.DistributeResp;

import java.nio.channels.SocketChannel;

public class DistributeReqHandler extends BaseHandler {

    @Override
    BaseResponse handle(Root baseRequest, Server server, Client client, SocketChannel socketChannel) {
        DistributeReq request = (DistributeReq) baseRequest;
        ServerContext serverContext = request.getServerContext();
        // 更新客户端数据
        GlobalContext.setClientContext(serverContext);

        DistributeResp resp = new DistributeResp();
        resp.setStatus(ResponseEnum.SUCCESS.getCode());
        resp.setCode(BizEnum.DISTRIBUTE_RESP.getCode());
        return resp;
    }
}
